﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Samples.ServiceHosting.StorageClient;

namespace StickDrawing_WebRole
{
    public partial class Gallery : System.Web.UI.Page
    {
        public List<string> listSD = new List<string>();

        protected void Page_Load(object sender, EventArgs e)
        {

            if (CommonVariables.StickDrawingCachList.Count == 0)
            {

                StorageAccountInfo accountInfo = StorageAccountInfo.GetAccountInfoFromConfiguration("TableStorageEndpoint");
                TableStorage.CreateTablesFromModel(typeof(StickDrawingDataServiceContext), accountInfo);
                StickDrawingDataServiceContext context = new StickDrawingDataServiceContext(accountInfo);


                CommonVariables.StickDrawingCachList = context.StickDrawings.ToList();


            }

            List<StickDrawing> listEntity = CommonVariables.StickDrawingCachList;
            listEntity.Reverse();
            
            foreach (StickDrawing s in listEntity)
           {
               listSD.Add(s.Guid);
           }

            for (int i = 1; i <= 60-listEntity.Count; i++)
            {
                listSD.Add("3275062198262");
            }

       //for (int i = 1; i <= 60; i++)
       //   {
       //         listSD.Add("3275062198262");
       //    }
    }
    }
}
